package top.infopub.tdp.util;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import top.infopub.model.sys.ErrorLog;
import top.infopub.tdp.sys.service.ErrorLogService;
import top.infopub.util.SpringContext;


/**
 * 系统异常日志工具类
 * @author Awoke
 * @version 2018年9月28日
 * @see ErrorLogUtil
 * @since
 */
public final class ErrorLogUtil {

    private static final Logger log = LoggerFactory.getLogger(ErrorLogUtil.class);

    private static ErrorLogService errorLogService = null;

    private static ErrorLogService getErrorLogService() {
        if (errorLogService == null) {
            errorLogService = SpringContext.getBean("errorLogServiceImpl");
        }
        return errorLogService;
    }

    /**
     * 插入日志
     * @param model 
     * @see
     */
    public static void log(ErrorLog model) {
        try {
            getErrorLogService().insert(model);
        }
        catch (Exception e) {
            log.error("", e);
        }
    }

}
